import 'package:flutter/material.dart';

// Builder构造函数
// 固定测轴水平方向子元素个数,无论如何宣战屏幕测轴子元素个数永远不变\
class GridViewBuilderWidget extends StatelessWidget {
  const GridViewBuilderWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.amber,
        title: const Text('案例-GridViewBuilder'),
      ),
      //  body: GridView.builder(
      body: GridView.count(
        crossAxisCount: 3,
        mainAxisSpacing: 10,
        crossAxisSpacing: 5,
        childAspectRatio: 4 / 3,
        children: List.generate(20, (index) {
          return Container(
            color: Colors.greenAccent,
            alignment: Alignment.center,
            child: Text("我学习我无敌$index"),
          );
        }),
      ),
    );
  }
}
